package com.hairline.controller;

import com.hairline.bean.vo.BaseRespVo;
import com.hairline.service.WxCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("wx/collect")
public class WxCollectController {
    @Autowired
    WxCollectService wxCollectService;


    @PostMapping("addordelete")
    public BaseRespVo addOrDelete(@RequestBody Map map) {
        byte type = 0;
        if (((Integer) map.get("type")) == 1) {
            type = 1;
        }
        Integer valueId = (Integer) map.get("valueId");
        Integer userId = 18;
        Map<String, String> result = wxCollectService.addOrDelete(type, valueId, userId);
        return BaseRespVo.ok(result);
    }

    @GetMapping("list")
    public BaseRespVo collectList(Integer type, Integer page, Integer size) {
        Integer userId=18;
        HashMap<String, Integer> map = new HashMap<>();
        map.put("type", type);
        map.put("page", page);
        map.put("size", size);
        map.put("userId",userId);
        Map<String, Object> result = wxCollectService.collectList(map);
        return BaseRespVo.ok(result);
    }
}
